package yf.mall.dao;

import org.apache.ibatis.annotations.Param;
import yf.mall.entity.MonthShareEntity;
import yf.mall.vo.MonthShareSortVo;
import yf.mall.vo.MonthShareVo;
import org.apache.ibatis.annotations.Mapper;
import com.yf.dao.BaseDao;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
 * 月销Dao
 *
 *
 *
 * @date Thu Oct 07 17:01:18 CST 2021
 */
@Mapper
public interface MonthShareDao extends BaseDao<MonthShareEntity> {

    List<MonthShareVo> findVo(MonthShareVo vo);

    MonthShareVo getVo(Long id);

    List<MonthShareEntity> findByUser(@Param("userId") Long userId, @Param("date") Date date);
    MonthShareEntity findByUserId(@Param("userId") Long userId, @Param("date") Date date);

    List<MonthShareEntity> findByOrderNo(@Param("orderNo") String orderNo, @Param("date") Date date);
    List<MonthShareEntity> findByDate(@Param("date") Date date);
    List<MonthShareEntity> findByStartDateAndEndDate(@Param("startDate") Date startDate,@Param("endDate") Date endDate,@Param("amount") Integer amount);


    //统计月销数量
    int sumQuantity(@Param("userId") Long userId, @Param("date") Date date);

    BigDecimal sumAmount(@Param("date") Date date);

    List<MonthShareSortVo> sortQuantity(@Param("date") Date date, @Param("team") Integer team);

    //自购 + 新分享  + 下级自购的
    List<MonthShareSortVo> sortQuantityByTeam(@Param("date") Date date);

    void removeByOrderNo(String orderNo);


    //减少业绩
    void decreaseSum(@Param("orderNo") String orderNo, @Param("amount") BigDecimal amount);

}
